#include<iostream>
using namespace std;
int fun(int x)
{
	int ans = 0;
	int k;
	while (x) {
		k = x % 10;
		if (k == 2) {
			ans++;
		}
		x /= 10;
	}
	return ans;
}
int main()
{
	int l, r;
	cin >> l >> r;
	int sum = 0;
	for (int i = l; i <= r; i++) {
		sum += fun(i);
	}
	cout << sum << endl;
	return 0;
}